#ifndef FTR_H_
#define FTR_H_

#include "recbase.h"
#include "rectype.h"
#include "stdffield.h"
#include <string>
#include <vector>

namespace opsrc {
    namespace stdf {

        class Ftr : public opsrc::stdf::RecBase
        {
        public:
            Ftr(stdf_rec stdfrec,  int reclen, std::ios::pos_type fileRecFirstBytePosition, int orderindex, endian e, char* buf);
            virtual ~Ftr();

            const StdfField<long> getTestNumber() const;
            void setTestNumber(StdfField<long> testnum);

            const StdfField<int> getHeadNumber() const;
            void setHeadNumber(StdfField<int> headnum);

            const StdfField<int> getSiteNumber() const;
            void setSiteNumber(StdfField<int> sitenum);

            const StdfField<vector<bool> > getTestFlag() const;
            void setTestFlag(StdfField<vector<bool> > testflag);

            const StdfField<vector<bool> > getOptionFlag() const;
            void setOptionFlag(StdfField<vector<bool> > optflag);

            const StdfField<int> getCycleCount() const;
            void setCycleCount(StdfField<int> cyclcnt);

            const StdfField<long> getRelativeVectorAddress() const;
            void setRelativeVectorAddress(StdfField<long> relvadr);

            const StdfField<long> getRepeatedVectorCount() const;
            void setRepeatedVectorCount(StdfField<long> reptcnt);

            const StdfField<long> getPinFailureCount() const;
            void setPinFailureCount(StdfField<long> numfail);

            const StdfField<unsigned long> getXlogicalDeviceAddressFailure() const;
            void setXlogicalDeviceAddressFailure(StdfField<unsigned long> xfailad);

            const StdfField<unsigned long> getYlogicalDeviceAddressFailure() const;
            void setYlogicalDeviceAddressFailure(StdfField<unsigned long> yfailad);

            const StdfField<int> getVectorOffset() const;
            void setVectorOffset(StdfField<int> vectoff);

            const StdfField<int> getPmrCountIndexes() const;
            void setPmrCountIndexes(StdfField<int> rtnicnt);

            const StdfField<int> getProgramStateIndexes() const;
            void setProgramStateIndexes(StdfField<int> pgmicnt);

            const StdfField<vector<int> > getPmrArrayData() const;
            void setPmrArrayData(StdfField<vector<int> > rtnindx);

            const StdfField<vector<int> > getPmrArrayState() const;
            void setPmrArrayState(StdfField<vector<int> > rtnstat);

            const StdfField<vector<int> > getProgramsStateIndexArray() const;
            void setProgramStateArray(StdfField<vector<int> > pgmindx);

            const StdfField<vector<int> > getProgramStateDataArray() const;
            void setProgramStateDataArray(StdfField<vector<int> > pgmstat);

            const StdfField<int> getFailPinBitMapLength() const;
            void setFailPinBitMapLength(StdfField<int> failpin);

            const StdfField<string> getVectorModulePatternName() const;
            void setVectorModulePatternName(StdfField<string> vectnam);

            const StdfField<string> getTimeSetName() const;
            void setTimeSetName(StdfField<string> timeset);

            const StdfField<string> getVectorOpCode() const;
            void setVectorOpCode(StdfField<string> vectnam);

            const StdfField<string> getDescriptiveText() const;
            void setDescriptiveText(StdfField<string> testtxt);

            const StdfField<string> getAlarmId() const;
            void setAlarmId(StdfField<string> alrmid);

            const StdfField<string> getAdditonalProgramInfo() const;
            void setAdditionalProgramInfo(StdfField<string> progtxt);

            const StdfField<string> getAdditionalResultInfo() const;
            void setAdditionalResultInfo(StdfField<string> rslttxt);

            const StdfField<int> getPatternGenertorNumber() const;
            void setPatternGeneratorNumber(StdfField<int> patgnum);

            const StdfField<int> getEnabledComparatorBitMap() const;
            void setEnabledComparatorBitMap(StdfField<int> spinmap);

            void readFields(char *buf);
            
            // to read flag setting
            bool getFlagSetting(StdfField<vector<bool> >& stdffield, int pos) const;

        protected:
            Ftr();

        private:
            endian en;
            StdfField<long> test_num;
            StdfField<int> head_num;
            StdfField<int> site_num;
            StdfField<vector<bool> > test_flag;
            StdfField<vector<bool> > opt_flag;
            StdfField<int> cycl_cnt;
            StdfField<long> rel_vadr;
            StdfField<long> rept_cnt;
            StdfField<long> num_fail;
            StdfField<unsigned long> xfail_ad;
            StdfField<unsigned long> yfail_ad;
            StdfField<int> vect_off;
            StdfField<int> rtn_icnt;
            StdfField<int> pgm_icnt;
            StdfField<vector<int> > rtn_indx;
            StdfField<vector<int> > rtn_stat;
            StdfField<vector<int> > pgm_indx;
            StdfField<vector<int> > pgm_stat;
            StdfField<int> fail_pin;
            StdfField<string> vect_nam;
            StdfField<string> time_set;
            StdfField<string> op_code;
            StdfField<string> test_txt;
            StdfField<string> alrm_id;
            StdfField<string> prog_txt;
            StdfField<string> rslt_txt;
            StdfField<int> patg_num;
            StdfField<int> spin_map;

            bool decodeFields;


            /*
 TEST_NUM U*4 Test number
HEAD_NUM U*1 Test head number
SITE_NUM U*1 Test site number
TEST_FLG B*1 Test flags (fail, alarm, etc.)
OPT_FLAG B*1 Optional data flag See note
CYCL_CNT U*4 Cycle count of vector OPT_FLAG bit 0 = 1
REL_VADR U*4 Relative vector address OPT_FLAG bit 1 = 1
REPT_CNT U*4 Repeat count of vector OPT_FLAG bit 2 = 1
NUM_FAIL U*4 Number of pins with 1 or more failures OPT_FLAG bit 3 = 1
XFAIL_AD I*4 X logical device failure address OPT_FLAG bit 4 = 1
YFAIL_AD I*4 Y logical device failure address OPT_FLAG bit 4 = 1
VECT_OFF I*2 Offset from vector of interest OPT_FLAG bit 5 = 1
RTN_ICNT U*2 Count (j) of return data PMR indexes See note
PGM_ICNT U*2 Count (k) of programmed state indexes See note
RTN_INDX jxU*2 Array of return data PMR indexes RTN_ICNT = 0
RTN_STAT jxN*1 Array of returned states RTN_ICNT = 0
PGM_INDX kxU*2 Array of programmed state indexes PGM_ICNT = 0
PGM_STAT kxN*1 Array of programmed states PGM_ICNT = 0
FAIL_PIN D*n Failing pin bitfield length bytes = 0
VECT_NAM C*n Vector module pattern name length byte = 0
TIME_SET C*n Time set name length byte = 0
OP_CODE C*n Vector Op Code length byte = 0
TEST_TXT C*n Descriptive text or label length byte = 0
ALARM_ID C*n Name of alarm length byte = 0
PROG_TXT C*n Additional programmed information length byte = 0
RSLT_TXT C*n Additional result information length byte = 0
PATG_NUM U*1 Pattern generator number 255
SPIN_MAP D*n Bit map of enabled comparators length byte = 0 

*/			

        };

    }  // namespave stdf
}		// namespace opsrc

#endif /*FTR_H_*/
